<template>
  <div class="add_address">
    <van-nav-bar
        left-text="新增地址"
        right-text="···"
        left-arrow
        @click-left="$router.go(-1)"
        />
        <!-- 添加地址 -->
    <div class="content">
        <div class="contacts">
            <span>联系人</span>
            <input type="text" placeholder="姓名" v-model="input.name">
            <br>
            <div class="sex">
                <button>男</button>
                <button>女</button>
            </div>
        </div>
        <div class="phone">
            <span>电话</span>
            <input type="text" placeholder="手机号码" v-model="input.phone">
        </div>
        <div class="address">
            <span>地址</span>
            <input type="text" placeholder="选择收获地址" v-model="input.address">
        </div>
        <div class="h_number">
            <span>门牌号</span>
            <input type="text" placeholder="例：5号楼203室">
        </div>
        <div class="label">
            <span>标签</span>
            <div class="sex">
                <button>家</button>
                <button>学校</button>
                <button>公司</button>
            </div>
        </div>
        <div class="btn">
            <div class="btnclick"  @click="request_address_build(input)">保存并使用</div>
        </div>
    </div>
  </div> 
</template>

<script>
import {address_add} from '../utils/api'
import { mapState,mapMutations,mapGetters,mapActions } from 'vuex'

export default {
    data(){
        return {
            input:{
                userid:JSON.parse(localStorage.getItem('userinfo')).id,
                address:'',
                phone:'',
                name:'',
            }
        }
    },
    methods:{
        ...mapActions(['request_address_build']),
    }
}
</script>

<style lang="scss" scoped>
.add_address{
    background-color: #fff;
}
//联系人
.content{
    margin: 10px;
    .contacts{
        height: auto;
        margin-top: 10px;
        position: relative;
        border-bottom: 1px solid rgb(241, 241, 241);
        padding: 5px;
        span{
            font-size: 14px;
            font-weight: bold;
        }
        input{
            width: 250px;
            right: 0;
            position: absolute;
            margin-left: 40px;
            height: 25px;
            border: none;
        }
        input::-webkit-input-placeholder{
            font-size: 14px;
            color: #aab2bd;
        }

        .sex{
            width: 150px;
            margin: 5px 90px ;
            display: flex;
                button{
                width: 60px;
                height: 25px;
                margin-left: 10px;
                background-color: #fff;
                border: 1px solid #aab2bd;
                margin-top: 10px;
                font-size: 12px;
                border-radius: 5px;
                
            }
        }
    }
    //电话
    .phone{
        height: 30px;
        margin-top: 10px;
        position: relative;
        border-bottom: 1px solid rgb(241, 241, 241);
        padding: 5px;
        span{
            font-size: 14px;
            font-weight: bold;
        }
        input{
            width: 250px;
            right: 0;
            position: absolute;
            margin-left: 40px;
            height: 25px;
            border: none;
        }
        input::-webkit-input-placeholder{
            font-size: 14px;
            color: #aab2bd;
        }
    }
    //地址
    .address{
        height: 30px;
        margin-top: 10px;
        position: relative;
        border-bottom: 1px solid rgb(241, 241, 241);
        padding: 5px;
        span{
            font-size: 14px;   
            font-weight: bold;
        }
        input{
            width: 250px;
            height: 25px;
            right: 0;
            position: absolute;
            margin-left: 40px;
            height: 25px;
            border: none;
        }
        input::-webkit-input-placeholder{
            font-size: 14px;
            color: #aab2bd;
        }
    }
    // 门牌号
    .h_number{
        height: 30px;
        margin-top: 10px;
        position: relative;
        border-bottom: 1px solid rgb(241, 241, 241);
        padding: 5px;
        span{
            font-size: 14px;  
            font-weight: bold; 
        }
        input{
            width: 250px;
            height: 25px;
            right: 0;
            position: absolute;
            margin-left: 40px;
            height: 25px;
            border: none;
        }
        input::-webkit-input-placeholder{
            font-size: 14px;
            color: #aab2bd;
        }
    }
    //标签
    .label{
        height: 30px;
        margin-top: 10px;
        position: relative;
        display: flex;
        justify-content: space-between;
        border-bottom: 1px solid rgb(241, 241, 241);
        padding: 5px;
        span{
            font-size: 14px;  
            font-weight: bold; 
        }
        .sex{
            width: auto;
            display: flex;
                button{
                width: 60px;
                height: 25px;
                margin-left: 10px;
                background-color: #fff;
                border: 1px solid #aab2bd;
                font-size: 12px;
                border-radius: 5px;
                
            }
        }
    }
    .btn{
        // display: block;
        width: 100%;
        height: 50px;
        color: white;
        .btnclick{
            margin: 10px auto;
            text-align: center;
            width: 80%;
            height: 40px;
            line-height: 40px;
            border-radius: 5px;
            background-image: linear-gradient(45deg, rgb(0, 165, 254), rgb(0, 130, 254));
        }
    }
}
</style>